package com.pactera.madp.cp.controller.sidebar.marketing;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pactera.madp.common.core.util.R;
import com.pactera.madp.cp.api.vo.marketing.MarketingRecVO;
import com.pactera.madp.cp.common.util.PageUtil;
import com.pactera.madp.cp.service.MarketingRecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;

/**
 * @Auther: yuShen.qi
 * @Date: 2021/5/25:16:06
 * @Description:
 */
@RestController
@RequestMapping("/marketingrecwechat")
@Api(value = "marketingRec", tags = "营销素材-分类管理-推荐侧边栏")
public class MarketingRecSidebarController {

    /**
     * 服务对象
     */
    @Resource
    private MarketingRecService marketingRecService;

    /**
     * 查询已添加在推荐榜单中的数据
     *
     * @return
     */
   @GetMapping("/page")
   @ApiOperation(value = "查询已添加在推荐榜单中的数据")
   public R<Page<MarketingRecVO>> list(Page page, Integer type, String title){
       List<MarketingRecVO> marketingRecVOS = marketingRecService.allListWechat(page, type, title);
       //根据sort排序
       marketingRecVOS.sort(Comparator.comparing(v->v.getSort()));
       return R.ok(PageUtil.split(marketingRecVOS,(int)page.getCurrent(),(int)page.getSize()));
   }

}
